package com.cfs.svcimpl.sys;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.core.Context;

import com.cfs.dao.sys.UserDao;
import com.cfs.svc.sys.LoginService;
import com.cfs.vo.Res;
import com.cfs.po.sys.User;
import com.util.CONST;

public class LoginServiceImpl implements LoginService {

	private UserDao dao = null;

	public UserDao getDao() {
		return dao;
	}

	public void setDao(UserDao dao) {
		this.dao = dao;
	}


	@Override
	public Res<User> login(User u, HttpServletRequest req) {
		Res<User> res = new Res<User>();
		User pu = dao.getCheckPass(u.getName(), u.getPass());
		if(pu==null){
			res.setCode(-1);
			res.setMsg("拒绝登录!");
		}else{
			HttpSession session = req.getSession();
			session.setAttribute(CONST.SESSION_USER, pu);
		}
		res.setObj(pu);

		return res;
	}
	
}
